home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / INTERNET / SITES / KELLIS / KEMD.ZIP / KEMD / ADVANCDX.TRA / SHELL.DIF < prev   
Encoding:
Text File  |  1994-08-10  |  16.9 KB  |  320 lines

  1. Archive-name: unix-faq/shell/shell-differences
  2. Version: 1.07
  3.  
  4.    The following article answers the frequently asked questions, what
  5.    UNIX shells are available, what are the differences between them and
  6.    how do you change your interactive shell.
  7.  
  8. Contents
  9.  
  10.      * Modifications since last issue
  11.      * Why change your shell
  12.      * The history of unix shells
  13.      * Deciding on a shell
  14.      * Shell features (table)
  15.      * How to change your shell
  16.      * A warning about changing your shell
  17.      * Further information
  18.      * Copyright and Disclaimer
  19.  
  20. Modifications since last issue
  21.  
  22.      * Removed the mini advert, I've got a job now so I don't need it any
  23.        more. Many thanks everyone who responded on this issue.
  24.      * Minor modifications to the wording in the shell history section
  25.        for the csh, zsh and rc entries.
  26.      * Clarified what I consider to the C Shell for the purposes of the
  27.        shell features table.
  28.      * Fixed a couple of entries in the table for (t)csh (thanks to Chris
  29.        Zoulas for these)
  30.  
  31. Why change your shell
  32.  
  33.    The UNIX shell is most people's main access to the UNIX operating
  34.    system and as such any improvement to it can result in considerably
  35.    more effective use of the system, and may even allow you to do things
  36.    you couldn't do before. The primary improvement most of the new
  37.    generation shells give you is increased speed. They require fewer key
  38.    strokes to get the same results due to their completion features, they
  39.    give you more information (e.g. showing your directory in your prompt,
  40.    showing which files it would complete) and they cover some of the more
  41.    annoying features of UNIX, such as not going back up symbolic links to
  42.    directories.
  43.  
  44. A brief history of UNIX shells
  45.  
  46.    In the near beginning there was the Bourne shell /bin/sh (written by
  47.    S. R. Bourne). It had (and still does) a very strong powerful
  48.    syntactical language built into it, with all the features that are
  49.    commonly considered to produce structured programs; it has
  50.    particularly strong provisions for controlling input and output and in
  51.    its expression matching facilities. But no matter how strong its input
  52.    language is, it had one major drawback; it made nearly no concessions
  53.    to the interactive user (the only real concession being the use of
  54.    shell functions and these were only added later) and so there was a
  55.    gap for something better.
  56.  
  57.    Along came the people from UCB and the C-shell /bin/csh was born. Into
  58.    this shell they put several concepts which were new, (the majority of
  59.    these being job control and aliasing) and managed to produce a shell
  60.    that was much better for interactive use. But as well as improving the
  61.    shell for interactive use they also threw out the baby with the bath
  62.    water and went for a different input language.
  63.  
  64.    The theory behind the change was fairly good, the new input language
  65.    was to resemble C, the language in which UNIX itself was written, but
  66.    they made a complete mess of implementing it. Out went the good
  67.    control of input and output and in came the bugs. The new shell was
  68.    simply too buggy to produce robust shell scripts and so everybody
  69.    stayed with the Bourne shell for that, but it was considerably better
  70.    for interactive use so changed to the C shell, this resulted in the
  71.    stupid situation where people use a different shell for interactive
  72.    work than for non-interactive, a situation which a large number of
  73.    people still find themselves in today.
  74.  
  75.    After csh was let loose on an unsuspecting world various people
  76.    decided that the bugs really should get fixed, and while they where at
  77.    it they might as well add some extra features. In came command line
  78.    editing, TENEX-style completion and several other features. Out went
  79.    most of the bugs, but did the various UNIX operating system
  80.    manufacturers start shipping tcsh instead of csh? No, most of them
  81.    stuck with the standard C-Shell, adding non-standard features as they
  82.    went along.
  83.  
  84.    Eventually David Korn from AT&T had the bright idea to sort out this
  85.    mess and the Korn shell /bin/ksh made its appearance. This quite
  86.    sensibly junked the C shells language and reverted back to the bourne
  87.    shell language, but it also added in the many features that made the C
  88.    shell good for interactive work (you could say it was the best of both
  89.    worlds), on top of this, it also added a some features from other
  90.    operating. The Korn shell became part of System V but had one major
  91.    problem; unlike the rest of the UNIX shells it wasn't free, you had to
  92.    pay AT&T for it.
  93.  
  94.    It was at about this time that the first attempts to standardize UNIX
  95.    started in the form of the POSIX standard. POSIX specified more or
  96.    less the System V Bourne Shell (by this time the BSD and System V
  97.    versions had got slightly different). Later the standard is upgraded,
  98.    and somehow the new standard managed to look very much like ksh.
  99.  
  100.    Also at about this time the GNU project was underway and they decided
  101.    that they needed a free shell, they also decided that they wanted to
  102.    make this new shell POSIX compatible, thus bash (the Bourne again
  103.    shell) was born. Like the Korn shell bash was based upon the Bourne
  104.    shells language and like the Korn shell, it also pinched features from
  105.    the C shell and other operating systems (in my opinion it put them
  106.    together better; guess which shell I use), but unlike the Korn shell
  107.    it is free. Bash was quickly adopted for LINUX (where it can be
  108.    configured to perform just like the Bourne shell), and is the most
  109.    popular of the free new generation shells.
  110.  
  111.    Meanwhile Tom Duff faced with the problem of porting the Bourne shell
  112.    to Plan 9, revolts and writes rc instead, he publishes a paper on it,
  113.    and Byron Rakitzis reimplements it under UNIX. With the benefit of a
  114.    clean start Rc ended up smalled, simpler, more regular and in most
  115.    peoples opinion a much cleaner shell.
  116.  
  117.    The search for the perfect shell still goes on and the latest entry
  118.    into this arena is zsh. Zsh was written by Paul Falstad while he was a
  119.    student a Princeton and suffers from a slight case of feeping
  120.    creaturism. It is based roughly on the bourne shell (although there
  121.    are some minor but important differences) and has so many additional
  122.    features that I don't even think the author even knows all of them.
  123.  
  124. Deciding on a shell
  125.  
  126.    Which of the many shells you choose depends on many different things,
  127.    here is what I consider to be the most important, you may think
  128.    differently.
  129.  
  130.    How much time do I have to learn a new shell?
  131.           There is no point in using a shell with a different syntax, or
  132.           a completly different alias system if you havn't the time to
  133.           learn it. If you have the time and are presently using csh or
  134.           tcsh it is worth considering a switch to a Bourne shell
  135.           variant.
  136.  
  137.    What do I wish to be able to do with my new shell?
  138.           The main reason for switching shells is to gain extra
  139.           functionality; its vital you know what you are gaining from the
  140.           switch.
  141.  
  142.    Do I have to be able to switch back to a different shell?
  143.           If you may have to switch back to a standard shell, it is
  144.           fairly important you don't become too dependent on extra
  145.           features and so can't use an older shell.
  146.  
  147.    How much extra load can the system cope with?
  148.           The more advanced shells tend to take up extra CPU, since they
  149.           work in cbreak mode; if you are on an overloaded machine they
  150.           should probably be avoided; this can also cause problems with
  151.           an overloaded network. This only really applies to very old
  152.           systems nowadays.
  153.  
  154.    What support is given for my new shell?
  155.           If your new shell is not supported make sure you have someone
  156.           you can ask if you encounter problems or that you have the time
  157.           to sort them out yourself.
  158.  
  159.    What shell am I using already?
  160.           Switching between certain shells of the same syntax is alot
  161.           easier than switching between shells of a different syntax. So
  162.           if you havn't much time a simple upgrade (eg csh to tcsh) may
  163.           be a good idea.
  164.  
  165.    Can I afford any minor bugs?
  166.           Like most software all shells have some bugs in them
  167.           (especially csh), can you afford the problems that may occur
  168.           because of them.
  169.  
  170. Shell features
  171.  
  172.    This table below lists most features that I think would make you
  173.    choose one shell over another. It is not intended to be a definitive
  174.    list and does not include every single possible feature for every
  175.    single possible shell. A feature is only considered to be in a shell
  176.    if in the version that comes with the operating system, or if it is
  177.    available as compiled directly from the standard distribution. In
  178.    particular the C shell specified below is that available on SUNOS 4.*,
  179.    a considerable number of vendors now ship either tcsh or their own
  180.    enhanced C shell instead (they don't always make it obvious that they
  181.    are shipping tcsh.
  182.  
  183.                                         sh   csh   ksh  bash tcsh zsh  rc
  184. Job control                             N    Y     Y    Y    Y    Y    N
  185. Aliases                                 N    Y     Y    Y    Y    Y    N
  186. Shell functions                         Y(1) N     Y    Y    N    Y    Y
  187. "Sensible" Input/Output redirection     Y    N     Y    Y    N    Y    Y
  188. Directory stack                         N    Y     Y    Y    Y    Y    N
  189. Command history                         N    Y     Y    Y    Y    Y    N(7)
  190. Command line editing                    N    N     Y    Y    Y    Y    N(7)
  191. Vi Command line editing                 N    N     Y    Y    Y(3) Y    N(7)
  192. Emacs Command line editing              N    N     Y    Y    Y    Y    N(7)
  193. Rebindable Command line editing         N    N     N    Y    Y    Y    N(7)
  194. User name look up                       N    Y     Y    Y    Y    Y    N(7)
  195. Login/Logout watching                   N    N     N    N    Y    Y    N
  196. Filename completion                     N    Y(1)  Y    Y    Y    Y    N(7)
  197. Username completion                     N    Y(2)  Y    Y    Y    Y    N(7)
  198. Hostname completion                     N    Y(2)  Y    Y    Y    Y    N(7)
  199. History completion                      N    N     N    Y    Y    Y    N(7)
  200. Fully programmable Completion           N    N     N    N    Y    Y    N
  201. Mh Mailbox completion                   N    N     N    N(4) N(6) N(6) N
  202. Co Processes                            N    N     Y    N    N    Y    N
  203. Builtin artithmetic evaluation          N    Y     Y    Y    Y    Y    N
  204. Can follow symbolic links               N    N     Y    Y    Y    Y    N
  205. Periodic command execution              N    N     N    N    Y    Y    N
  206. Custom Prompt (easily)                  N    N     Y    Y    Y    Y    Y
  207. Sun Keyboard Hack                       N    N     N    N    N    Y    N
  208. Spelling Correction                     N    N     N    N    Y    Y    N
  209. Process Substitution                    N    N     N    Y(2) N    Y    Y
  210. Underlying Syntax                       sh   csh   sh   sh   csh  sh   rc
  211. Freely Available                        N    N     N(5) Y    Y    Y    Y
  212. Checks Mailbox                          N    Y     Y    Y    Y    Y    N(8)
  213. Tty Sanity Checking                     N    N     N    N    Y    Y    N
  214. Can cope with large argument lists      Y    N     Y    Y    Y    Y    Y
  215. Has non-interactive startup file        N    Y     Y(9) Y(9) Y    Y    N
  216. Has non-login startup file              N    Y     Y(9) Y    Y    Y    N
  217. Can avoid user startup files            N    Y     N    Y    N    Y    Y
  218. Can specify startup file                N    N     Y    Y    N    N    N
  219.  
  220.    Notes to the table above
  221.     1. This feature was not in the orginal version, but has since become
  222.        almost standard.
  223.     2. This feature is fairly new and so is often not found on many
  224.        versions of the shell, it is gradually making its way into
  225.        standard distribution.
  226.     3. The Vi emulation of this shell is thought by many to be
  227.        incomplete.
  228.     4. This feature is not standard but unoffical patches exist to
  229.        perform this.
  230.     5. A version called 'pdksh' is freely available, but does not have
  231.        the full functionality of the AT&T version.
  232.     6. This can be done via the shells programmable completion mechanism.
  233.     7. A library can be linked into the shell to provide this feature.
  234.     8. This can be done via the shells prompt function.
  235.     9. Only by specifing a file via the ENV environment variable.
  236.  
  237. How to change your shell
  238.  
  239.  
  240.    If you ever look at a UNIX manual page it will say that to change your
  241.    shell use chsh or passwd -s; unfortunately it often isn't as simple as
  242.    this, since it requires that your new shell is recognized as a valid
  243.    shell by the system and at present many systems do not recognize the
  244.    newer shells (the normal selection is, /bin/sh, /bin/csh and possibly
  245.    /bin/ksh). You are thus left with having to do some sort of fudge,
  246.    changing your effective login shell without changing your official
  247.    entry in /etc/passwd. You may also be left with the problem that there
  248.    isn't a compiled binary on your system , so you will have to get hold
  249.    of the shell's source and compile it yourself (Its generally best to
  250.    ask around to see if anyones done this already, since it isn't that
  251.    easy). Once done you should add in code to your old shells login file
  252.    so that it overlays your official login shell with your new shell
  253.    (remember to add the login flags to the command line, and with
  254.    csh/tcsh ensure that the overlay doesn't happen recursively since they
  255.    both read the same .login file).
  256.  
  257.    The shell can be recognized as a valid shell if the system
  258.    administrator puts it in the file /etc/shells. If this file does not
  259.    exist, it must be created and should contain all valid shells
  260.    (i.e.don't forget the traditional ones in all their forms).
  261.  
  262. WARNING
  263.  
  264.    If you do decide to change your shell you must be very careful - if
  265.    handled wrongly it can be almost impossible to correct, and will
  266.    almost certainly cause you a lot of hassle. Never make a new shell a
  267.    login shell until you have tested its new configuration files
  268.    thoroughly and then tested them once again. It is also important that
  269.    you make a full backup of your previous config files onto a floppy
  270.    disk (or a different host if you have a second account) if you have to
  271.    change any of them (which you will probably have to do if you can't
  272.    change your shell entry in /etc/passwd). You should also note that
  273.    your new shell is probably not supported by your system admin, so if
  274.    you have any problems you will probably have to look elsewhere.
  275.  
  276. Further information
  277.  
  278.    The Bourne shell, the C-Shell and the Korn Shell (if you have it) are
  279.    all distributed as standard with your UNIX operating system,
  280.    information on these should come with your operating system, bug
  281.    reports etc should be sent to your operating system vendor.
  282.  
  283.    Bash was written and is maintained by the Free Software Foundation,
  284.    the primary source of information for this shell is its manual page.
  285.    Bug reports should be sent to bash-maintainers@ai.MIT.Edu, while
  286.    suggestions and philosophical bug reports may be mailed to
  287.    bug-bash@ai.MIT.Edu or posted to the Usenet newsgroup gnu.bash.bug,
  288.    the source is widely available on many ftp sites, and is subject to
  289.    the GNU copyleft licence.
  290.  
  291.    Rc is available by ftp from ftp:viz.tamu.edu/pub/rc and several other
  292.    places. An FAQ exists and is posted frequently to comp.unix.shell and
  293.    other places. The Rc mailing list may be subscribed to by sending mail
  294.    to rc-request@hawkwind.utcs.toronto.edu, this, the manual page and
  295.    the Rc FAQ are the main sources of information for this shell.
  296.  
  297.    Zsh is now maintained by the zsh mailing list, which can be subscribed
  298.    to by sending email to Majordomo@sterling.com containing subscribe
  299.    zsh-list, there is also an FAQ which is posted frequently to
  300.    comp.unix.shell. The manual page, the Z-shell FAQ and the zsh-list are
  301.    the main sources of information for this shell.
  302.  
  303.    Questions on any of the UNIX shells and on shell script programming,
  304.    may be posted to the Usenet newsgroup comp.unix.shell a quick response
  305.    can normally be expected, especially on subjects relating to the more
  306.    common shells.
  307.  
  308. Copyright and Disclaimer
  309.  
  310.    Copyright to this document is kept by the author, but freedom is given
  311.    to distribute it as long as no money is made from its distribution,
  312.    without the prior concent of the author. The author also does not
  313.    guarantee that the information it contains is correct, although every
  314.    effort is done to ensure that it is.
  315.  
  316.    Email relating to the content of this document should be sent to
  317.    shell-diff@gryphon.demon.co.uk.
  318.  
  319.     Brian Blackmore, bnb@gryphon.demon.co.uk
  320.